<!-- 管理员权限组新增和编辑页面 -->
<extend name="Public/base" />
<block name="body">
    <!--<div class="main-title">
        <h2>{:L("_DEFAULT_TITLE_CONFIGURATION_")}</h2>
    </div>-->
    <div class="tab-wrap with-padding">

        <div class="clearfix">
            <div class="col-xs-10">
                <include file="_link"/>
            </div>
            <div class="col-xs-2 text-right">
                <select name="role" class="form-control">
                    <volist name="role_list" id="vo">
                        <option value="{:U('Role/configRank',array('id'=>$vo['id']))}" <eq name="vo['id']" value="$this_role['id']">selected</eq> >{$vo.title}</option>
                    </volist>
                </select>
            </div>
        </div>
        <div class="node-list">
            <!-- 访问授权 -->
            <div class="tab-pane in">
                <form action="__SELF__" enctype="application/x-www-form-urlencoded" method="POST" class="form-horizontal auth-form">
                    <div>
                        <h4>{:L("_DEFAULT_TITLE_AND_LABEL_CONFIGURATION_")}</h4>
                        <span>{:L("_USER_DEFAULT_TITLE_AND_LABEL_CONFIGURATION_")}</span>
                    </div>

                    <div class="col-xs-4" style="padding-left: 0">
                        <notempty name="can_apply">
                            <dl class="checkmod">
                                <dt class="hd">
                                    <label class="checkbox"><input class="auth_rank rank_all" type="checkbox">{:L("_USER_CAN_APPLY_FOR_TITLE_")}</label>
                                </dt>
                                <dd class="bd">
                                    <volist name="can_apply" id="rank" >
                                        <div class="rank_check">
                                            <div>
                                                <label class="checkbox" title="id：{$rank['id']} {:L('_CREATE_PERSON_')}{$rank['name']} {:L('_CREATE_TIME_')}{$rank['create_time']|time_format='Y-m-d'}">
                                                <input class="auth_rank rank_row" type="checkbox" name="ranks[]" value="{$rank['id']}"/>{$rank['title']}
                                                <empty name="rank.label_content"><img src="{$rank['logo']|getThumbImageById}"/><else/>
                                                    <span class="label label-badge rank-label" title="{$rank.title}" style="line-height: 6px;height: 18px;vertical-align: middle;text-align: center; background: {$rank.label_bg} !important;color:{$rank.label_color} !important;">{$rank.label_content}</span>
                                                </empty>
                                                </label>
                                            </div>
                                        </div>
                                    </volist>
                                    <div class="clearfix"></div>
                                </dd>
                            </dl>
                        </notempty>

                        <notempty name="un_apply">
                            <dl class="checkmod">
                                <dt class="hd">
                                    <label class="checkbox"><input class="auth_rank rank_all" type="checkbox">{:L("_USERS_CAN_NOT_APPLY_FOR_THE_TITLE_")}</label>
                                </dt>
                                <dd class="bd">
                                    <volist name="un_apply" id="rank" >
                                        <div class="rank_check">
                                            <div>
                                                <label class="checkbox" title="id：{$rank['id']} 创建人{$rank['name']} 创建时间{$rank['create_time']|time_format='Y-m-d'}">
                                                <input class="auth_rank rank_row" type="checkbox" name="ranks[]" value="{$rank['id']}"/>{$rank['title']}<img src="{$rank['logo']|getThumbImageById}"/>
                                                </label>
                                            </div>
                                        </div>
                                    </volist>
                                    <div class="clearfix"></div>
                                </dd>
                            </dl>
                        </notempty>
                        <if condition="count($un_apply)||count($can_apply)">
                            <label class="item-label">{:L("_TITLE_ISSUES_")}</label>
                            <div class="controls">
                                <textarea name="reason" style="width: 500px;min-height: 100px;">{$reason}</textarea>
                            </div>
                            <else/>
                            <div style="color: #B5B4B4;font-size: 16px;margin: 10px 0;">
                                {:L("_FIRST_TO_THE_USER_TITLE_MANAGEMENT_TITLE_LIST_WITH_SPACE_")}中<a href="{:U('admin/rank/editrank')}" target="_blank" title={:L("_ADD_THE_TITLE_RIGHT_NOW_WITH_DOUBLE_")} style="color: #B5B4B4;text-decoration: underline;">{:L("_ADD_A_TITLE_")}</a>~
                            </div>
                        </if>
                    </div>

                    <div class="col-xs-4">
                        <notempty name="tag_list">
                            <volist name="tag_list" id="tag_group">
                                <dl class="checkmod">
                                    <dt class="hd">
                                        <label class="checkbox"><input class="auth_fields fields_all" type="checkbox">{$tag_group.title}</label>
                                    </dt>
                                    <dd class="bd">
                                        <present name="tag_group['tag_list']">
                                            <volist name="tag_group['tag_list']" id="tag">
                                                <div class="filed_check">
                                                    <div>
                                                        <label class="checkbox">
                                                            <input class="auth_fields fields_row" type="checkbox" name="tags[]" value="{$tag.id}"/>【{$tag.id}】{$tag.title}
                                                        </label>
                                                    </div>
                                                </div>
                                            </volist>
                                        </present>
                                        <div class="clearfix"></div>
                                    </dd>
                                </dl>
                            </volist>
                            <else/>
                            <div style="margin: 10px;color: rgb(255, 81, 81);">{:L("_FIRST_PLEASE_GO_TO_THE_USER_THE_USER_LABEL_MANAGEMENT_TAB_LIST_WITH_SPACE_")}中<a href="{:U('Admin/UserTag/userTag')}" title="" target="_blank" style="color: rgb(255, 81, 81);text-decoration: underline;">{:L("_ADD_USER_TAGS_")}</a>~</div>
                        </notempty>
                    </div>

                    <div class="col-xs-12" style="margin-top: 20px">
                        <input type="hidden" name="id" value="{$this_role.id}" />
                        <button type="submit" class="btn submit-btn ajax-post" target-form="auth-form">{:L("_STEP_NEXT_")}</button>
                        <button class="btn btn-return" onclick="javascript:history.back(-1);return false;">{:L("_RETURN_WITH_SPACE_")}</button>
                        <span style="color: #BABABA;margin: 11px;">{:L("_PLEASE_SAVE_THE_ABOVE_CONFIGURATION_AND_THEN_SWITCH_TO_ANOTHER_INTERFACE_")}</span>
                    </div>
                </form>
            </div>
        </div>
    </div>
    <style>
        .rank_check{
            float: left;
            margin: 20px 20px 20px 0;
        }
        .rank_check img{
            margin-left: 5px;
            width: 18px;
            height: 18px;
        }
    </style>
</block>
<block name="script">
    <script type="text/javascript" src="__STATIC__/qtip/jquery.qtip.min.js"></script>
    <link rel="stylesheet" type="text/css" href="__STATIC__/qtip/jquery.qtip.min.css" media="all">
    <script type="text/javascript" charset="utf-8">
        +function($){
            var ranks = [{$this_role.ranks}];
        $('.auth_rank').each(function(){
            if( $.inArray( parseInt(this.value,10),ranks )>-1 ){
                $(this).prop('checked',true);
            }
            if(this.value==''){
                $(this).closest('span').remove();
            }
        });

        //全选节点
        $('.rank_all').on('change',function(){
            $(this).closest('dl').find('dd').find('input').prop('checked',this.checked);
        });
        $('.rank_row').on('change',function(){
            $(this).closest('.rank_check').find('.child_row').find('input').prop('checked',this.checked);
        });

        $('.checkbox').each(function(){
            $(this).qtip({
                content: {
                    text: $(this).attr('title'),
                    title: $(this).text()
                },
                position: {
                    my: 'bottom center',
                    at: 'top center',
                    target: $(this)
                },
                style: {
                    classes: 'qtip-dark',
                    tip: {
                        corner: true,
                        mimic: false,
                        width: 10,
                        height: 10
                    }
                }
            });
        });

        $('select[name="role"]').change(function(){
            location.href = this.value;
        });
        //导航高亮
        highlight_subnav('{:U('Role/configrank')}');

            var fields = [{$this_role_tag.fields}];
            $('.auth_fields').each(function () {
                if ($.inArray(parseInt(this.value, 10), fields) > -1) {
                    $(this).prop('checked', true);
                }
                if (this.value == '') {
                    $(this).closest('span').remove();
                }
            });

            //全选节点
            $('.fields_all').on('change', function () {
                $(this).closest('dl').find('dd').find('input').prop('checked', this.checked);
            });
            $('.fields_row').on('change', function () {
                $(this).closest('.filed_check').find('.child_row').find('input').prop('checked', this.checked);
            });

            $('.checkbox').each(function () {
                $(this).qtip({
                    content: {
                        text: $(this).attr('title'),
                        title: $(this).text()
                    },
                    position: {
                        my: 'bottom center',
                        at: 'top center',
                        target: $(this)
                    },
                    style: {
                        classes: 'qtip-dark',
                        tip: {
                            corner: true,
                            mimic: false,
                            width: 10,
                            height: 10
                        }
                    }
                });
            });

            $('select[name="role"]').change(function () {
                location.href = this.value;
            });
            //导航高亮
            highlight_subnav('{:U('Role/configusertag')}');
        }(jQuery);
    </script>
</block>
